
/**评分切换存放值*/
function selectfen(name,i,n){
   if(name == "three"){
   $("#hidden_stvalue").val(i);
   }else if(name == "four"){
   $("#hidden_hjvalue").val(i);
   }else if(name == "five"){
   $("#hidden_fwvalue").val(i);
   }else if(name == "six"){
   $("#hidden_cwvalue").val(i);
   }
   setTab1(name,i/2,n);
}

 
/**影院评分*/
function addScore(){
var cinematoken = $("#cinematoken").val();
var stvalue = $("#hidden_stvalue").val();
var hjvalue = $("#hidden_hjvalue").val();
var fwvalue = $("#hidden_fwvalue").val();
var cwvalue = $("#hidden_cwvalue").val();
if(""==stvalue&&""==hjvalue&&""==fwvalue&&""==cwvalue) return;
var url=ticket_host+"/jquery-second038.html?cinemaId="+pageCinemaId;
 $.post(url, {"stvalue":stvalue,"hjvalue":hjvalue,"fwvalue":fwvalue,"cwvalue":cwvalue,"cinetoken":cinematoken}, function(data){
        var dt=data.split(",");
        if(data == "false"){
        //	tipsWindownNew( "提交失败!","520", "170","0")
        	tipsWindownNew( "亲，你已经点过一次了！明天再来吧！","520", "170","0")
		}else if(dt[0] == "outcount"){ //超过点击次数
				$("#cinematoken").val(dt[1]);
				tipsWindownNew( "亲，你已经点过一次了！明天再来吧！","520", "170","0")
		}else{
			$("#cinematoken").val(data);
			tipsWindownNew( "提交成功！","520", "170","0")
		}
 });
}
 /**
 * 展示影院评论信息
 * 
 */
function rentcontent(){
	if(filmallsize==0){
		setTab1('one',2,4);
		$('#hotfilm').hide();
		$('#show_detail_all').hide();
	}
	checkRecentCinemas();
		$.ajax({
		type : "post",
		url :ticket_host+ "/cinema-" + pageCinemaId+"/"+version,
		data : {
			cinemaId : pageCinemaId,
			datatype : 'cinemasize'
		},
		dataType:"text",
		success : function(filmComments) {
		 var strs= new Array();
		 strs=filmComments.split("::");
		$("#sizepages").empty();
		$("#sizepages").html(strs[0]);
		if(strs[1]>2){
			$("#commore").css('display','block'); 
		}else{
			$("#commore").css('display','none'); 
		}
		}
	});
}

/**
 * 点击事件
 * 
 */
function setTab1(name, cursel, n) {
	for (i = 1; i <= n; i++) {
		var menu = document.getElementById(name + i);
		var con = document.getElementById("j_" + name + "_" + i);
		 menu.className = i == cursel ? "hover" : "";
		con.style.display = i == cursel ? "block" : "none";
	}
}
/**
 * 场次信息
 * @param cinemaId å½±é¢id
 * @param filmId   å½±çid
 * @param showDate åºæ¬¡æ¶é´
 */
function getShow(cinemaId,filmId,showDate) {
	$(".details_sh").hide();
	$.ajax({
		type : "post",
		url : ticket_host+ "/cinema-" + pageCinemaId+"/"+version,
		data : {
			cinemaId : cinemaId,
			filmId : filmId,
			showDate : showDate,
			datatype : 'shows'
		},
		dataType:"json",
		success : function(msg) {
			var resultJson=convertToJsonObject(msg);
			$("#showInfo").empty();
			$("#showInfo").html(resultJson.showHtml);
			$("#filmInfo").html(resultJson.filmHtml);
			$("#showInfo").css("opacity",0).animate({opacity:'1'},300);
			$("#filmInfo").css("opacity",0).animate({opacity:'1'},300);
		}
	});
}
//欢乐汇点击事件

/**
 *影院评论信息
 *@param cinemaid
*/
function getCinemacomment() {

}
/**
 * 点击影院获取场次
 * @param filmId å½±çid
 */
function clickFilm(clickFilmId) {
	pageFilmId=clickFilmId;
	getShow(pageCinemaId,pageFilmId, pageShowDate);
}

/**
 * ç¹å»åºæ¬¡æ¶é´è¿è¡çæä½
 * @param filmId å½±çid
 */
function clickShowDate(clickShowDate,dateId) {
	pageShowDate=clickShowDate;
	$("#cinema_all li").attr("class","tr");
	$("#"+dateId).attr("class","on tr");
	getShow(pageCinemaId,pageFilmId,pageShowDate);
}

/**
 * 点击评论tab
 * @param index
 */
function clickCinemaComment(index){
	  setTab1(index,3,4);//展示tab
	//获取影评展示	
		$.ajax({
		type : "post",
		url :ticket_host+ "/cinema-" + pageCinemaId+"/"+version,
		data : {
			cinemaId : pageCinemaId,
			datatype : 'filmComment'
		},
		dataType:"text",
		success : function(filmComments) {
			 var strs= new Array();
			 strs=filmComments.split("::");
		$("#cinemaComments").empty();
		$("#cinemaComments").html(strs[0]);
		$.ajax({
		type : "post",
		url :ticket_host+ "/cinema-" + pageCinemaId+"/"+version,
		data : {
			cinemaId : pageCinemaId,
			datatype : 'cinemapage',
			num:1
		},
		dataType:"text",
		success : function(filmComments) {
			 var strs= new Array();
			 strs=filmComments.split("::");
		$("#pagecontent").empty();
		$("#pagecontent").html(strs[0]);
		
		}
	});
		}
	});
		
}
/**
 * 点击页面tab
 * @param index
 */
function clickpagenext(index){
	//获取影评展示	
		$.ajax({
		type : "post",
		url : ticket_host+ "/cinema-" + pageCinemaId+"/"+version,
		data : {
			cinemaId : pageCinemaId,
			datatype : 'filmComment',
			num:index
		},
		dataType:"text",
		success : function(filmComments) {
			 var strs= new Array();
			 strs=filmComments.split("::");
		$("#cinemaComments").empty();
		$("#cinemaComments").html(strs[0]);
		$.ajax({
		type : "post",
		url : ticket_host+ "/cinema-" + pageCinemaId+"/"+version,
		data : {
			cinemaId : pageCinemaId,
			datatype : 'cinemapage',
			num:index
		},
		dataType:"text",
		success : function(filmComments) {
			
		$("#pagecontent").empty();
		$("#pagecontent").html(filmComments);
		
		}
	});
		}
	});
}
/**
 * 初始化影平
 * @param filmComments 服务器返回的jsonObject数组
 */
function showCinemaComment(cinemaComment){
	var cinemaCommentObjects=convertToJsonObject(cinemaComment);
	var html="";
	for (var index in cinemaCommentObjects){
		var cinemaCommentObject =cinemaCommentObjects[index];
		var singleHtml="<li class=\"bdb_f2\">"
			+"<div class=\"fl\">"
			+" <img src=\""+cinemaCommentObject.userHead+"\"> "
			+"	<div class=\"tc fs0\">"
			+"		 "+cinemaCommentObject.userName
			+"	</div>"
			+"</div>"
			+"<div class=\"fl w730 ml20 mt10\">"
			+"	<div class=\"fs0 f14\">"
			+cinemaCommentObject.commentContent
			+"	</div>"
			+"	<div class=\"fsc8 mt7\">"
			+"		来自:蜘蛛电影票网页版 "+cinemaCommentObject.createDate
			+"	</div>"
			+"</div>";
		html+=singleHtml;
	}
	$("#cinemaComments").html(html);	
}

/**
 * 转换变量为对象,常用于服务器返回json数据时
 * @param object
 * @returns
 */
function convertToJsonObject(object){
	return object;
}
/**
 * 发表评论
 * @param title
 * @returns {Boolean}
 */
function addcinemacomment(cinemaName,textAreaId){
    var comment = $("#"+textAreaId).val();//评论内容
    if(""== $.trim(comment)){
    	 tipsWindownNew( "评论不能为空","520", "170","0")
		  return; 
    }
    if("这家影院我有话说"==comment){
		 tipsWindownNew( "评论不能为空","520", "170","0")
		  return; 
	}
    if(comment.length<6){
    	tipsWindownNew( "评论不能小于六个字","520", "170","0")
		  return; 
    }
    $.ajax({
		type : "post",
		url : ticket_host+ "/jquery-first014.html",
		data : {
			cinemaId : pageCinemaId,
			comment :  comment,
			filmId : "",
			title:cinemaName,
			star:0//默认值
		},
		contentType: "application/x-www-form-urlencoded; charset=utf-8", 
		success : function(data) {
			if(data == "login"){
				onclickLogin();
			//	tipsWindownNew( "请先登录！","520", "170","0")
			}else if(data == "false"){
				tipsWindownNew( "发表评论失败！","520", "170","0")
			}else{
				tipsWindownNew( "提交成功！看来很有见谛！","520", "170","0")
				 $("#"+textAreaId).val("");
			}
		}
	});
}



/**
 * 附近的影院信息
 *@param distance 附近影院的距离
*/
function postRecentCinemas(distance) {
	$.ajax({
		type : "post",
		url :ticket_host+ "/cinema-" + pageCinemaId+"/"+version,
		data : {
			cinemaId : pageCinemaId,
			datatype : 'recentCinema',	
			distance: distance
		},
		dataType:"json",
		success : function(recentCinemas) {
			showRecentCinemas(recentCinemas,distance);
		}
	});
}
/**
 * 点击附近影院tab
 * @param distance 附近影院的距离
 * @param indexOne 
 * @param indexTwo 
 */
function clickRecentCinemas(distance,indexOne,indexTwo){
	setTab1('seven',indexOne,indexTwo);//展示tab
	getRecentCinemas(distance);//获取附近影院展示
}
/**
 * 附近的影院信息
 *@param distance 附近影院的距离
*/
function getRecentCinemas(distance) {
	$.ajax({
		type : "post",
		url :ticket_host+ "/cinema-" + pageCinemaId+"/"+version,
		data : {
			cinemaId : pageCinemaId,
			datatype : 'recentCinema',	
			distance: distance
		},
		dataType:"json",
		success : function(recentCinemas) {
			showRecentCinemas(recentCinemas,distance);
		}
	});
}
/**
 * 附近的影院信息
 *@param distance 附近影院的距离
*/
function checkRecentCinemas() {
	$.ajax({
		type : "post",
		url :ticket_host+ "/cinema-" + pageCinemaId+"/"+version,
		data : {
			cinemaId : pageCinemaId,
			datatype : 'checkrecentCinema'
		},
		dataType:"json",
		success : function(recentCinemas) {
			if(true==recentCinemas){
				$("#recentcinemaall").show();
				getRecentCinemas(3);
			}
			if(false==recentCinemas)
			{
				$("#recentcinemaall").hide();	
				$("#recentCinemas").hide();	
			}
			
			//showRecentCinemas(recentCinemas);
		}
	});
}

/**
 * 附近的影院信息展示
 * @param recentCinemas 服务器返回的jsonObject数组
 */
function showRecentCinemas(recentCinemas,distance){
	if(0==recentCinemas.length){
		temp = "0~3";
		if(6==distance)temp="3~6";
		if(9==distance)temp="6~9"
		 $("#recentCinemas").html("附近"+temp+"公里内无影院");
		 return;
	}
	var html="";
	for (var index in recentCinemas){
		var recentCinema=recentCinemas[index]
		
		var cinemaScore1 = recentCinema.score;
		var cinemaScore2 = 0;
		var cinemaScore=recentCinema.score; //这是一字符串 
		if (cinemaScore.indexOf('.')>0){
			var cinemaScores=cinemaScore.split("."); //字符分割 
			if(cinemaScores.length=2){
				cinemaScore1 = cinemaScores[0];
				cinemaScore2 = cinemaScores[1];
			}
		}		
		var singleHtml="<li><div class=\"fs0\">"
		+"<a href="+ticket_host+ "/cinema-"+recentCinema.cinemaId+"/"+version+" class=\"fs0_a\">"+recentCinema.cinemaName+"</a>"
		+"<em class=\"f18 redff ml10\"><span class=\"f30\">"+cinemaScore1+".</span>"+cinemaScore2+"</em>"						  
		+"</div>"
		+"<div class=\"fsa0\">"
		+"地址："+recentCinema.address
		+"<br />"
		+"电话："+recentCinema.contact									  
		+"</div></li>"
		  html+=singleHtml;
	    }
	    $("#recentCinemas").html(html);
 }

function userdetail(customerid){
	var url_remote =  "/jquery-first045.html?customerid=" + customerid+"&type=star";
	var bool  = "";
	$.post(url_remote, null, function(data){
		var items = data.getElementsByTagName("item");
		var flag = items[0].childNodes[0].nodeValue;
		if(flag==0){
			bool = items[1].childNodes[0].nodeValue;
			$(".faceawall").html(bool);
			$(".close").click(function(){
				closeFaceWalls();
			});
			$(".mask").click(function(){
				closeFaceWalls();
			});
			$(".faceawall .pic li").JNMagnifier({
				renderTo : ".ShowBigPictureBox"
			});
		}else{
			$(".faceawall").html(bool);
		}
		
	});		
	if($(".mask").length<=0){
		$("body").append("<div class='mask' style='display:none'></div>");
	}
	$(".mask").show();
	$(".faceawall").show();
}
function textareaMaxlimit(str){
	if("index"==str){
		var index = $("#publishedindex").val();
		index = index.replace(/\s+/g,""); 
		if(index.length>1000){
			$("#publishedindex").val(index.substring(0, 1000));
			return;
		}
		$("#fcontentindex").empty();
		$("#fcontentindex").append(1000-index.length);
	}else if("detail"==str){
		var detail = $("#publisheddetail").val();
		detail = detail.replace(/\s+/g,""); 
		if(detail.length>1000){
			$("#publisheddetail").val(detail.substring(0, 1000));
			return;
		}
		$("#fcontentdetail").empty();
		$("#fcontentdetail").append(1000-detail.length);
	}
	}
 

 
 
 
 
 











